var vm_jingfeipicidanweiqueren = new Vue({
    el: "#jingfeipicidanweiqueren",
    data: {
        jingfeipiciid: $("#jingfeipiciid").val(),//经费批次id,
        deptid: $("#deptid").val(),//上级单位id,

        //查询字段
        deptname : '',
        shifouqueren : '',

        danweiquerenlist : [],

        //编辑用
        currentdeptid : '',
        currentpiciid : '',
        jiezhishijian : '',
    },
    created : function(){
        var _this = this;

        _this.bindDanweiList();

    },
    methods: {
        bindDanweiList : function(){
            var _this = this;

            var jingfeipici_layer = layer.open({type:3});
            $.post('/system/queren/finddanweiquerenbyparentid', {
                deptid : _this.deptid,
                jingfeipiciid : _this.jingfeipiciid,
                deptname : _this.deptname,
                shifouqueren : _this.shifouqueren,
                rdm : Math.random()
            },function(ppData) {
                layer.close(jingfeipici_layer);

                if (ppData != null) {
                    if (ppData.result==1){
                        var data = ppData.resultContent;
                        _this.danweiquerenlist = data;
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },

        getJiezhishijian:function(){
            var _this = this;

            _this.jiezhishijian=$("#jiezhishijian").val();
        },

        toShezhi:function(danweiquerenitem){

            var _this = this;

            _this.currentdeptid = danweiquerenitem.jigoudaima;
            _this.currentpiciid = _this.jingfeipiciid;

            _this.bindShezhi();
            $("#kaifangModal").modal();

        },

        bindShezhi:function(){
            var _this = this;

            var jingfeipici_layer = layer.open({type:3});
            $.post('/system/kaifang/findone', {
                deptid : _this.currentdeptid,
                jingfeipiciid : _this.currentpiciid,
                rdm : Math.random()
            },function(ppData) {
                layer.close(jingfeipici_layer);

                if (ppData != null) {
                    if (ppData.result==1){

                        _this.jiezhishijian  =ppData.resultContent.jiezhishijian;
                        $("#jiezhishijian").val(_this.jiezhishijian);

                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },

        Shezhi:function(){
            var _this = this;

            var jingfeipici_layer = layer.open({type:3});
            $.post('/system/kaifang/shezhi', {
                deptid : _this.currentdeptid,
                jingfeipiciid : _this.currentpiciid,
                jiezhishijian : _this.jiezhishijian,
                rdm : Math.random()
            },function(ppData) {
                layer.close(jingfeipici_layer);

                if (ppData != null) {
                    if (ppData.result==1){
                        layer.open({
                            time: 1000,
                            btn: [],
                            content: "设置成功!",
                        });
                        $("#kaifangModal").modal('hide');
                        _this.bindDanweiList();
                    }else{
                        layer.alert(ppData.message);
                    }
                }
            },"json");
        },
    },

})